/*
 * @Author: 胡海
 * @Date: 2020-02-10 19:39:49
 * @LastEditors: 胡海
 * @LastEditTime: 2020-03-07 11:56:50
 * @Description: 
 */
class HttpException extends Error {
    constructor(msg = '服务器异常', errorCode = 10000, code = 400) {
        super()
        this.errorCode = errorCode
        this.code = code
        this.msg = msg
    }
}

class ParameterException extends HttpException {
    constructor(msg, errorCode) {
        super()
        this.code = 400
        this.msg = msg || '参数错误'
        this.errorCode = errorCode || 10000
    }
}

class Success extends HttpException {
    constructor(msg, errorCode) {
        super()
        this.code = 201
        this.msg = msg || 'ok'
        this.errorCode = errorCode || 0
    }
}

class Successd extends HttpException {
    constructor(data, msg, errorCode) {
        super()
        this.code = 201
        this.msg = msg || 'ok'
        this.errorCode = errorCode || 0
        this.data = data
    }
}

class NotFound extends HttpException {
    constructor(msg, errorCode) {
        super()
        this.msg = msg || '资源未找到'
        this.errorCode = errorCode || 10000
        this.code = 404
    }
}

class AuthFailed extends HttpException {
    constructor(msg, errorCode) {
        super()
        this.msg = msg || '授权失败'
        this.errorCode = errorCode || 10004
        this.code = 401
    }
}

class Forbbiden extends HttpException {
    constructor(msg, errorCode) {
        super()
        this.msg = msg || '禁止访问'
        this.errorCode = errorCode || 10006
        this.code = 403
    }
}

class LikeError extends HttpException {
    constructor(msg, errorCode) {
        super()
        this.code = 400
        this.msg = msg || "请勿重复提交"
        this.errorCode = 60001
    }
}

class DislikeError extends HttpException {
    constructor(msg, errorCode) {
        super()
        this.code = 400
        this.msg = "你已取消点赞"
        this.errorCode = 60002
    }
}


module.exports = {
    HttpException,
    ParameterException,
    Success,
    Successd,
    NotFound,
    AuthFailed,
    Forbbiden,
    LikeError,
    DislikeError
}